package com.gitee.llj.tools.base;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * <p></p>
 *
 * @Author llj
 * @Date 2018/3/27
 */
public class ResultModel<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private String success;
    private String message;
    private T data;

    public String getSuccess() {
        return this.success;
    }

    public void setSuccess(String success) {
        this.success = success;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public ResultModel() {
    }

    public ResultModel(String success, String message) {
        this.success = success;
        this.message = message;
    }

    public ResultModel(String success, String message, T data) {
        this.success = success;
        this.message = message;
        this.data = data;
    }

    public ResultModel(ResultStatus status) {
        this.success = String.valueOf(status.getSuccess());
        this.message = status.getMessage();
    }

    public ResultModel(ResultStatus status, T data) {
        this.success = String.valueOf(status.getSuccess());
        this.message = status.getMessage();
        if (data != null && !"".equals(data.toString())) {
            this.data = data;
        } else {
            this.data = data;
        }

    }

    public static ResultModel ok(Object content) {
        return new ResultModel(ResultStatus.SUCCESS, content);
    }

    public static ResultModel ok() {
        return new ResultModel(ResultStatus.SUCCESS);
    }

    public static ResultModel error(ResultStatus error) {
        return new ResultModel(error);
    }

    public static ResultModel noPermissions() {
        return new ResultModel(ResultStatus.USER_NOT_PERMISSIONS);
    }
}
